/**
 * Copyright (c) 2010 Simple Graph Tools contributors. All rights reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * $Id$
 */
package org.sgt.testdef.impl;

import java.util.Map;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.impl.EFactoryImpl;
import org.eclipse.emf.ecore.plugin.EcorePlugin;
import org.sgt.testdef.ETestResult;
import org.sgt.testdef.ExpectedResult;
import org.sgt.testdef.Requirement;
import org.sgt.testdef.Step;
import org.sgt.testdef.TestCase;
import org.sgt.testdef.TestCondition;
import org.sgt.testdef.TestConstraint;
import org.sgt.testdef.TestParameter;
import org.sgt.testdef.TestPlan;
import org.sgt.testdef.TestSuite;
import org.sgt.testdef.TestdefFactory;
import org.sgt.testdef.TestdefPackage;


/**
 * <!-- begin-user-doc -->
 * An implementation of the model <b>Factory</b>.
 * <!-- end-user-doc -->
 * @generated
 */
public class TestdefFactoryImpl extends EFactoryImpl implements TestdefFactory {
	/**
	 * Creates the default factory implementation.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public static TestdefFactory init() {
		try {
			TestdefFactory theTestdefFactory = (TestdefFactory)EPackage.Registry.INSTANCE.getEFactory("http://www.sgt.org/testdef/1.0.0/testdef.ecore"); 
			if (theTestdefFactory != null) {
				return theTestdefFactory;
			}
		}
		catch (Exception exception) {
			EcorePlugin.INSTANCE.log(exception);
		}
		return new TestdefFactoryImpl();
	}

	/**
	 * Creates an instance of the factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TestdefFactoryImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public EObject create(EClass eClass) {
		switch (eClass.getClassifierID()) {
			case TestdefPackage.TEST_SUITE: return createTestSuite();
			case TestdefPackage.INTEGER2_CASES_MAP: return (EObject)createInteger2CasesMap();
			case TestdefPackage.TEST_CASE: return createTestCase();
			case TestdefPackage.STEP: return createStep();
			case TestdefPackage.REQUIREMENT: return createRequirement();
			case TestdefPackage.INTEGER2_STEP_MAP: return (EObject)createInteger2StepMap();
			case TestdefPackage.TEST_PLAN: return createTestPlan();
			case TestdefPackage.TEST_PARAMETER: return createTestParameter();
			case TestdefPackage.EXPECTED_RESULT: return createExpectedResult();
			case TestdefPackage.TEST_CONDITION: return createTestCondition();
			case TestdefPackage.TEST_CONSTRAINT: return createTestConstraint();
			default:
				throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object createFromString(EDataType eDataType, String initialValue) {
		switch (eDataType.getClassifierID()) {
			case TestdefPackage.ETEST_RESULT:
				return createETestResultFromString(eDataType, initialValue);
			default:
				throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String convertToString(EDataType eDataType, Object instanceValue) {
		switch (eDataType.getClassifierID()) {
			case TestdefPackage.ETEST_RESULT:
				return convertETestResultToString(eDataType, instanceValue);
			default:
				throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TestSuite createTestSuite() {
		TestSuiteImpl testSuite = new TestSuiteImpl();
		return testSuite;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Map.Entry<Integer, TestCase> createInteger2CasesMap() {
		Integer2CasesMapImpl integer2CasesMap = new Integer2CasesMapImpl();
		return integer2CasesMap;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TestCase createTestCase() {
		TestCaseImpl testCase = new TestCaseImpl();
		return testCase;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Step createStep() {
		StepImpl step = new StepImpl();
		return step;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Requirement createRequirement() {
		RequirementImpl requirement = new RequirementImpl();
		return requirement;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Map.Entry<Integer, Step> createInteger2StepMap() {
		Integer2StepMapImpl integer2StepMap = new Integer2StepMapImpl();
		return integer2StepMap;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TestPlan createTestPlan() {
		TestPlanImpl testPlan = new TestPlanImpl();
		return testPlan;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TestParameter createTestParameter() {
		TestParameterImpl testParameter = new TestParameterImpl();
		return testParameter;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ExpectedResult createExpectedResult() {
		ExpectedResultImpl expectedResult = new ExpectedResultImpl();
		return expectedResult;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TestCondition createTestCondition() {
		TestConditionImpl testCondition = new TestConditionImpl();
		return testCondition;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TestConstraint createTestConstraint() {
		TestConstraintImpl testConstraint = new TestConstraintImpl();
		return testConstraint;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ETestResult createETestResultFromString(EDataType eDataType, String initialValue) {
		ETestResult result = ETestResult.get(initialValue);
		if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
		return result;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String convertETestResultToString(EDataType eDataType, Object instanceValue) {
		return instanceValue == null ? null : instanceValue.toString();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TestdefPackage getTestdefPackage() {
		return (TestdefPackage)getEPackage();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @deprecated
	 * @generated
	 */
	@Deprecated
	public static TestdefPackage getPackage() {
		return TestdefPackage.eINSTANCE;
	}

} //TestdefFactoryImpl
